class Solution(object):
    def distributeCandies(self, candyType):
        """
        :type candyType: List[int]
        :rtype: int
        """
        n = len(candyType)
        a_set = set()
        t = 0
        target = n // 2
        for i in range(n):
            if candyType[i] not in a_set:
                t += 1
                a_set.add(candyType[i])
                if t == target:
                    return t
        return t